import axios from 'axios';

/**
 * 供应商
 */
export class SupplierService {
  // 分页查询列表
  static findSuppliers(queryParams) {
    return axios({
      url: '/restaurant/material/Supplier/findSuppliers',
      method: 'POST',
      data: queryParams
    });
  }

  //根据ID查询指定的供应商
  static findSupplier(supplierId) {
    const query = {
      supplierId
    }
    return axios({
      url: '/restaurant/material/Supplier/findSupplier',
      method: 'POST',
      params: query,
    });
  }

  //根据ID查询指定的供应商(包含外键名称)
  static findSupplierForView(supplierId) {
    const query = {
      supplierId
    }
    return axios({
      url: '/restaurant/material/Supplier/findSupplierForView',
      method: 'POST',
      params: query,
    });
  }

  //根据ID查询指定的供应商(包含外键名称)
  static findSupplierForEdit(supplierId) {
    const query = {
      supplierId
    }
    return axios({
      url: '/restaurant/material/Supplier/findSupplierForEdit',
      method: 'POST',
      params: query,
    });
  }

  //根据ID查询指定的供应商(只提取ID 和 Name)
  static findSuppliersWithIdNameById(supplierId) {
    const query = {
      supplierId
    }
    return axios({
      url: '/restaurant/material/Supplier/findSuppliersWithIdNameById',
      method: 'POST',
      params: query,
    });
  }

  //根据名称查询供应商集合(只提取ID 和 Name)
  static findSuppliersWithIdNameByName(supplierName) {
    const query = {
      supplierName
    }
    return axios({
      url: '/restaurant/material/Supplier/findSuppliersWithIdNameByName',
      method: 'POST',
      params: query,
    });
  }

  //新增保存供应商
  static saveSupplier(supplier) {
    const query = {}
    return axios({
      url: '/restaurant/material/Supplier/saveSupplier',
      method: 'POST',
      params: query,
      data: supplier
    });
  }

  //修改保存供应商
  static updateSupplier(supplier) {
    console.log(supplier)
    return axios({
      url: '/restaurant/material/Supplier/updateSupplier',
      method: 'POST',
      data: supplier
    });
  }

  //根据ID查询指定的供应商(只提取ID 和 Name)
  static deleteSupplier(supplierId) {
    const query = {
      supplierId
    }
    return axios({
      url: '/restaurant/material/Supplier/deleteSupplier',
      method: 'POST',
      params: query,
    });
  }
}
